package com.heima.feign.article.fallbackFactory;

import com.heima.feign.article.ArticleClient;
import com.heima.model.article.dto.ArticleDto;
import com.heima.model.dtos.ResponseResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2023/1/13 21:21
 */
@Component
@Slf4j
public class ArticleClientFallbackFactory implements FallbackFactory<ArticleClient> {
    @Override
    public ArticleClient create(Throwable throwable) {
        return new ArticleClient(){

            @Override
            public ResponseResult<Long> saveArticle(ArticleDto articleDto) {
                log.info("远程调用Article feign接口出错：{}",throwable.getMessage());
                return null;
            }
        };
    }
}
